<template>
        <el-dialog ref="dialog" top="5%" title="新增" v-model="editFormVisible" :close-on-click-modal="false">
            <el-form ref="form" :model="form" :rules="rules" label-width="110px">
                <el-form-item label="姓名" prop="FName">
                    <el-input v-model="form.FName"></el-input>
                </el-form-item>
                <el-form-item label="性别">
                    <el-radio-group v-model="form.FSex">
                        <el-radio label="男"></el-radio>
                        <el-radio label="女"></el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="籍贯" prop="FOriginPlace">
                    <el-input v-model="form.FOriginPlace"></el-input>
                </el-form-item>
                <el-form-item label="年龄" prop="FAge">
                    <el-input v-model="form.FAge"></el-input>
                </el-form-item>
                <el-form-item label="职位">
                    <el-input v-model="form.FPosition"></el-input>
                </el-form-item>
                <el-form-item label="部门">
                    <el-input v-model="form.FDept"></el-input>
                </el-form-item>
                <el-form-item label="分管事务">
                    <el-input v-model="form.FForProject"></el-input>
                </el-form-item>
                <el-form-item label="手机">
                    <el-input v-model="form.FPhone"></el-input>
                </el-form-item>
                <el-form-item label="固定电话">
                    <el-input v-model="form.FTelphone"></el-input>
                </el-form-item>
                <el-form-item label="传真">
                    <el-input v-model="form.FFax"></el-input>
                </el-form-item>
                <el-form-item label="邮箱">
                    <el-input v-model="form.FEmail"></el-input>
                </el-form-item>
                <el-form-item label="QQ">
                    <el-input v-model="form.FQQ"></el-input>
                </el-form-item>
                <el-form-item label="微信">
                    <el-input v-model="form.FWx"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input type="textarea" v-model="form.FNote"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click.native="editFormVisible = false">取 消</el-button>
                <el-button v-if="authEdit" type="primary" @click="save" :loading="loading">保存</el-button>
            </div>
      </el-dialog>
</template>

<script>
    import util from '../../common/util'
    export default {
        data() {
            return {
                authEdit:false,
                form: {},
                rules: {
                    FName: [{required: true,message: '请输入姓名', trigger: 'blur'}]
                },
                loading:false,
                editFormVisible:false
            }
        },
        methods: {
            switchLoading(flag){
                this.loading = flag;
            },
            _openEdit(record,authEdit) {
                this.authEdit = authEdit
                this.editFormVisible = true;
                this.form = Object.assign({},record);
            },
            _openAdd(record) {
                this.authEdit = true
                this.editFormVisible = true;
                this.form = Object.assign({FID:0,FSex:""},record);
            },
            save:function () {
                util.post("server/customer/Contacts.ashx?cmd=Save",this.form,this.switchLoading,result=> {
                    util.msgSuc("保存成功")
                    this.editFormVisible = false
                    this.$emit("onSaveSuc",this.form)
                })
            }
        },
        mounted() {

        }
    }
</script>
